package cn.backpackerxl.util;

/**
 * @author: backpackerxl
 * @create: 2021/11/29
 * @filename: CodeToLong
 **/
public class CodeToLong {
    /**
     * 随机生成16位数的订单码或者6位验证码
     *
     * @return
     */
    public static char[] getCodeToLong(int len) {
        String mobile = "0123456789";
        char[] rands = new char[len];
        for (int i = 0; i < len; i++) {
            int rand = (int) (Math.random() * 9);
            rands[i] = mobile.charAt(rand);
        }
        return rands;
    }

    public static String getUserCode() {
        String chars = "0123456789qazxswedcvfrbgtnhymjukilopQAZXSWCDERFVBGTYHNMJUIKLOP";
        char[] rands = new char[10];
        for (int i = 0; i < 10; i++) {
            int rand = (int) (Math.random() * 61);
            rands[i] = chars.charAt(rand);
        }
        return "b" + String.valueOf(rands);
    }
}
